import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/cupertino.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/village_simple_component/component.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/village_simple_component/state.dart';

import 'effect.dart';
import 'reducer.dart';
import 'state.dart';
import 'view.dart';

class MainPage extends Page<MainState, Map<String, dynamic>> {
  MainPage()
      : super(
          initState: initMainPageState,
          effect: buildEffect(),
          reducer: buildReducer(),
          view: buildView,
          dependencies: Dependencies<MainState>(
              adapter: null,
              slots: <String, Dependent<MainState>>{
                'village-info': HouseConnector() + VillageSimpleComponent(),
              }),
          middleware: <Middleware<MainState>>[],
        );

  @override
  ComponentState<MainState> createState() {
    return IndexSingleTickerProviderState();
  }
}

class IndexSingleTickerProviderState extends ComponentState<MainState>
    with SingleTickerProviderStateMixin {}

class HouseConnector extends ConnOp<MainState, VillageSimpleState> {
  @override
  VillageSimpleState get(MainState state) {
    return state.villageState;
  }

  @override
  void set(MainState state, VillageSimpleState subState) {
    state.villageState = subState;
  }
}
